package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.ts.domain.query.ExaminationQuestionQuery;
import com.xy.biz.ts.domain.req.UpdateExaminationPaperRuleRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.ts.domain.bo.ExaminationPaperRuleBO;
import com.xy.biz.ts.domain.po.ExaminationPaperRulePO;
import com.xy.biz.ts.domain.query.ExaminationPaperRuleQuery;
import com.xy.biz.ts.domain.resp.GetExaminationPaperRuleResponse;
import com.xy.biz.ts.domain.req.SaveExaminationPaperRuleRequest;
import com.xy.biz.ts.domain.req.ListExaminationPaperRuleRequest;

/**
 *
 *
 * @author wwj
 * @date 2021-3-25
 */
public class ExaminationPaperRuleConverter {

    public static ExaminationPaperRulePO toPO(ExaminationPaperRuleBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperRulePO(), true);
    }

    public static List<ExaminationPaperRulePO> toPO(Collection<ExaminationPaperRuleBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationPaperRulePO(), true);
    }

    public static ExaminationPaperRuleBO fromPO(ExaminationPaperRulePO source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperRuleBO());
    }

    public static List<ExaminationPaperRuleBO> fromPO(Collection<ExaminationPaperRulePO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationPaperRuleBO());
    }

    public static ExaminationPaperRuleBO toBO(SaveExaminationPaperRuleRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperRuleBO(), true);
    }

    public static ExaminationPaperRuleBO toBO(UpdateExaminationPaperRuleRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new ExaminationPaperRuleBO(), true);
    }


    public static List<ExaminationPaperRuleBO> toBO(Collection<SaveExaminationPaperRuleRequest> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExaminationPaperRuleBO(), true);
    }

    public static GetExaminationPaperRuleResponse toResponse(ExaminationPaperRuleBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new GetExaminationPaperRuleResponse());
    }

    public static List<GetExaminationPaperRuleResponse> toResponse(Collection<ExaminationPaperRuleBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetExaminationPaperRuleResponse());
    }

    public static ExaminationPaperRuleQuery toQuery(ListExaminationPaperRuleRequest source) {
        if (null == source) {
            return null;
        }
        ExaminationPaperRuleQuery target = ExaminationPaperRuleQuery.max().build();
        BeanUtilsEx.copyProperties(source, target);
        return target;
    }

    public static ExaminationPaperRuleQuery toQuery(ExaminationPaperRuleBO source) {
        if (null == source) {
            return null;
        }
        ExaminationPaperRuleQuery target = new ExaminationPaperRuleQuery(0, 20);
        BeanUtilsEx.copyProperties(source, target);
        return target;
    }

}
